home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 30 < prev    next >
Text File  |  1996-08-06  |  2KB  |  42 lines

  1. Newsgroups: comp.std.c
  2. Path: phcoms4.seri.philips.nl!panther!baynes
  3. From: baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes)
  4. Subject: Re: Alignment of malloc()
  5. Sender: news@ukpsshp1.serigate.philips.nl (account for localnews)
  6. Message-ID: <DKp9L9.234@ukpsshp1.serigate.philips.nl>
  7. Date: Fri, 5 Jan 1996 08:43:57 GMT
  8. References: <DKDA7D.Kw7@midway.uchicago.edu> <j66Sx*FRe@yaps.rhein.de> <DKKHCH.L6r@midway.uchicago.edu> <4ccbdb$5v6@fg70.rz.uni-karlsruhe.de> <DKo8ns.8A9@midway.uchicago.edu>
  9. Organization: Philips Semiconductors, Southampton, UK
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Michael Spertus (mps@geodesic.com) wrote:
  13. : In article <4ccbdb$5v6@fg70.rz.uni-karlsruhe.de>,
  14. : Thomas Koenig <ig25@mvmap66.ciw.uni-karlsruhe.de> wrote:
  15. : >
  16. : >I know of no compiler which is as brain-damaged as the one you describe;
  17. : >when I encounter one, I'd tend to howl to the vendor.
  18. : >-- 
  19. : Many PC compilers have this problem (See the BYTEmark column in the
  20. : December BYTE). The problem is that Win32 GlobalAlloc(), which is
  21. : what most allocators use to get their arenas, returns a 32-bit aligned
  22. : pointer. Most standard library implementations will pass through this
  23. : alignment (probably because the implementor does not realize that
  24. : GlobalAlloc() does not align very well so that code for an sbrk()
  25. : based allocator cannot be used without change. They may also be unaware
  26. : that Pentium PCs use 64 bits data buses). This problem is magnified
  27. : because the Pentium (apparently) drops into microcode on nonaligned
  28. : loads, so that nonaligned floating point benchmarks are over 300%
  29. : slower.
  30.  
  31. This reminds me of a discussion over could calloc use the size parameter
  32. as a hint to give different alignment to malloc. For example:
  33.     calloc( N, sizeof( float ) )
  34. could recognize the sizeof float and give 64 bit alignment in this case.
  35. I recall the conclusion was that it could do this, but did not have to.
  36.    
  37. --
  38. Stephen Baynes                              baynes@mulsoc2.serigate.philips.nl
  39. Philips Semiconductors Ltd
  40. Southampton                                 My views are my own.
  41. United Kingdom
  42.